<template>
<view>
<view class="TUI-message-input-container">
    <!-- <view class="TUI-commom-function">
		<view v-for="(item, index) in commonFunction" :key="index" class="TUI-commom-function-item" :data-function="item" @tap="handleCommonFunctions">{{item.name}}</view>
    </view> -->
    <view class="TUI-message-input">
        <image class="TUI-icon" @tap="switchAudio" :src="isAudio ? '/static/static/assets/keyboard.svg' : '/static/static/assets/audio.svg'"></image>
        <view v-if="!isAudio" class="TUI-message-input-main">
            <input class="TUI-message-input-area" :adjust-position="true" cursor-spacing="20" v-model="inputText" @input="onInputValueChange" maxlength="140" type="text"  placeholder-class="input-placeholder" placeholder="说点什么呢~" @focus="inputBindFocus" @blur="inputBindBlur">
        </view>
        <view v-else class="TUI-message-input-main" @longpress="handleLongPress" @touchmove="handleTouchMove" @touchend="handleTouchEnd" style="display: flex; justify-content: center; font-size: 32rpx; font-family: PingFangSC-Regular;">
            <text>{{text}}</text>
        </view>
        <view class="TUI-message-input-functions" hover-class="none">
            <image class="TUI-icon" @tap="handleEmoji" src="/static/static/assets/face-emoji.svg"></image>
            <view v-if="!sendMessageBtn" @tap="handleExtensions">
                <image class="TUI-icon" src="/static/static/assets/more.svg"></image>
            </view>
            <view v-else class="TUI-sendMessage-btn" @tap="sendTextMessage">
                发送
            </view>
        </view>
    </view>
    <view v-if="displayFlag === 'emoji'" class="TUI-Emoji-area">
        <TUI-Emoji @enterEmoji="appendMessage"></TUI-Emoji>
    </view>
    <view v-if="displayFlag === 'extension'" class="TUI-Extensions">
        <!-- TODO: 这里功能还没实现 -->
<!--        <camera device-position="back" flash="off" binderror="error" style="width: 100%; height: 300px;"></camera>-->
        <view class="TUI-Extension-slot" @tap="handleSendPicture">
            <image class="TUI-Extension-icon" src="@/static/static/assets/take-photo.svg"></image>
            <view class="TUI-Extension-slot-name">拍摄照片</view>
        </view>
        <view class="TUI-Extension-slot" @tap="handleSendImage">
            <image class="TUI-Extension-icon" src="/static/static/assets/send-img.svg"></image>
            <view class="TUI-Extension-slot-name">发送图片</view>
        </view>
        <view class="TUI-Extension-slot" @tap="handleShootVideo">
            <image class="TUI-Extension-icon" src="/static/static/assets/take-video.svg"></image>
            <view class="TUI-Extension-slot-name">拍摄视频</view>
        </view>
		<view class="TUI-Extension-slot" @tap="handleSendVideo">
            <image class="TUI-Extension-icon" src="/static/static/assets/send-video.svg"></image>
            <view class="TUI-Extension-slot-name">发送视频</view>
        </view>
     <!--   <view class="TUI-Extension-slot" :data-value="1" @tap="handleCalling">
            <image class="TUI-Extension-icon" src="/static/static/assets/audio-calling.svg"></image>
            <view class="TUI-Extension-slot-name">语音通话</view>
        </view>
        <view class="TUI-Extension-slot" :data-value="2" @tap="handleCalling">
            <image class="TUI-Extension-icon" src="/static/static/assets/video-calling.svg"></image>
            <view class="TUI-Extension-slot-name">视频通话</view>
        </view> -->
		<!-- <view class="TUI-Extension-slot" @tap="handleServiceEvaluation">
		    <image class="TUI-Extension-icon" src="/static/static/assets/service-assess.svg"></image>
		    <view class="TUI-Extension-slot-name">服务评价</view>
		</view> -->
		<!-- <view class="TUI-Extension-slot" @tap="handleSendOrder">
		    <image class="TUI-Extension-icon" src="/static/static/assets/send-order.svg"></image>
		    <view class="TUI-Extension-slot-name">发送订单</view>
		</view> -->
        <view class="TUI-Extension-slot" @tap="handlePresent">
            <image class="TUI-Extension-icon" src="/static/static/images/present.png"></image>
            <view class="TUI-Extension-slot-name">发送礼物</view>
        </view>
        <view class="TUI-Extension-slot" @tap="handleSendMap">
            <image class="TUI-Extension-icon" src="/static/static/images/location.png"></image>
            <view class="TUI-Extension-slot-name">发送位置</view>
        </view>
		<!-- <view class="TUI-Extension-slot" @tap="handleSendnews">
		    <image class="TUI-Extension-icon" src="/static/static/images/location.png"></image>
		    <view class="TUI-Extension-slot-name">发送新闻</view>
		</view> -->
    </view>
    <TUI-Common-Words class="tui-cards" :display="displayCommonWords" @sendMessage="$handleSendTextMessage" @close="$handleCloseCards"></TUI-Common-Words>
	
    <TUI-Order-List class="tui-cards" :display="displayOrderList" @sendCustomMessage="$handleSendCustomMessage" @close="$handleCloseCards"></TUI-Order-List>
	
    <TUI-Service-Evaluation class="tui-cards" :display="displayServiceEvaluation" @sendCustomMessage="$handleSendCustomMessage" @close="$handleCloseCards"></TUI-Service-Evaluation>
	
	<TUI-Present class="tui-cards" :conversation="conversation" :display="displayPresent" @sendCustomMessage="$handleSendCustomMessage" @close="$handleCloseCards"></TUI-Present>
	
	<!-- 新闻 -->
	<TUInews  class="tui-cards" :conversation="conversation" :display="displaynews" @sendCustomMessage="$handleSendnews" @close="$handleCloseCards"></TUInews>

</view>
<view class="record-modal" v-if="popupToggle" @longpress="handleLongPress" @touchmove="handleTouchMove" @touchend="handleTouchEnd">
    <view class="wrapper">
        <view class="modal-loading">
        </view>
    </view>
    <view class="modal-title">
    {{title}}
    </view>
</view>
</view>
</template>

<script>
import TUIEmoji from "../message-elements/emoji/index";
import TUICommonWords from "../message-private/common-words/index";
import TUIOrderList from "../message-private/order-list/index";
import TUIServiceEvaluation from "../message-private/service-evaluation/index";
import TUIPresent from "../message-private/present/index";
import TUInews from "../message-private/news/index";
import {sendRights} from '@/common/config/chat.js'
// sendRights
export default {
  data() {
    return {
		// newsid:'',
      // todo  conversation
      // conversation: {},
      inputText: '',
      extensionArea: false,
      sendMessageBtn: false,
      displayFlag: '',
      isAudio: false,
      bottomVal: 0,
      startPoint: 0,
      popupToggle: false,
      isRecording: false,
      canSend: true,
      text: '按住说话',
      title: ' ',
      notShow: false,
      isShow: true,
      recordTime: 0,
      recordTimer: null,
	  // commonFunction: [
		 //  {
			// name: '礼物',
			// icon:'/static/static/images/present.png',
			// key: '1'
		 //  }, {
			// name: '定位',
			// icon:'/static/static/images/location.png',
			// key: '2'
		 //  } 
	  // ],
      commonFunction: [{
        name: '常用语',
        key: '0'
      }, {
        name: '发送订单',
        key: '1'
      }, {
        name: '服务评价',
        key: '2'
      }],
      displayServiceEvaluation: false,
      displayCommonWords: false,
      displayOrderList: false,
	  displayPresent:false ,// 礼物
	  displaynews:false
    };
  },
  inject: ['newsid'],
  components: {
    TUIEmoji,
    TUICommonWords,
    TUIOrderList,
    TUIServiceEvaluation,
	TUIPresent,
	TUInews
  },
  // #ifdef APP-PLUS
  props:['conversation'],
  // #endif
  // #ifdef MP-WEIXIN
  props: {
    conversation: {
      type: Object,
      default: () => {}
    }
  },  
  // #endif

  watch: {
	  // #ifdef APP-PLUS
	  conversation(e){
		  this.conversation=e
	  },
	  // #endif
	  // #ifdef MP-WEIXIN
		conversation: {
		  handler: function (newVal) {
			  // console.log(newVal,'newVal')
		    // todo 值会被改变
		    this.setData({
		      conversation: newVal
		    });
		  },
		  immediate: true,
		  deep: true
		}
	  // #endif
    
  },

 //  beforeMount() {
	//   uni.showToast({
	//     title:'1',
	//     icon: 'none'
	//   });
 //    // 加载声音录制管理器
 //    this.recorderManager = uni.getRecorderManager();
 //    this.recorderManager.onStop(res => {
	// 	uni.showToast({
	// 	  title:'2',
	// 	  icon: 'none'
	// 	});
 //      clearInterval(this.recordTimer);
 //      // 兼容 uniapp 打包app，duration 和 fileSize 需要用户自己补充
 //      // 文件大小 ＝ (音频码率) x 时间长度(单位:秒) / 8
	//   console.log(res,'resres')
	//   uni.showToast({
	//     title:res.tempFilePath,
	//     icon: 'none'
	//   });
 //      let msg = {
 //        duration: res.duration? res.duration : this.recordTime * 1000,
 //        tempFilePath: res.tempFilePath,
 //        fileSize: res.fileSize ? res.fileSize : (48 * this.recordTime) / 8 * 1024
 //      }
	  
	//   // return false
 //      uni.hideLoading();
 //      // 兼容 uniapp 语音消息没有duration
 //      if (this.canSend) {
 //        if (msg.duration < 1000) {
 //          uni.showToast({
 //            title: '录音时间太短',
 //            icon: 'none'
 //          });
 //        } else {
	// 		uni.showToast({
	// 		  title: '发送语音',
	// 		  icon: 'none'
	// 		});
 //          // res.tempFilePath 存储录音文件的临时路径
 //          const message = uni.$TUIKit.createAudioMessage({
 //            to: this.getToAccount(),
 //            conversationType: this.conversation.type,
 //            payload: {
 //              file: msg
 //            }
 //          });
 //          this.$sendTIMMessage(message);
 //        }
 //      }
	// // #ifdef MP-WEIXIN
	// this.setData({
	//   startPoint: 0,
	//   popupToggle: false,
	//   isRecording: false,
	//   canSend: true,
	//   title: ' ',
	//   text: '按住说话'
	// });
	// // #endif
 //    // #ifdef APP-PLUS
 //    this.startPoint= 0
 //    this.popupToggle=false
 //    this.isRecording=false
 //    this.canSend= true
 //    this.title= ' '
 //    this.text= '按住说话'
 //    // #endif  
 //    });
 //  },
 mounted() {
	 // console.log(this.newsid,'newsid')
 	if(this.newsid.id){
		this.displaynews=true
	}
 },	
  methods: {
	  fs() {
		  // 加载声音录制管理器
		  this.recorderManager = uni.getRecorderManager();
		  this.recorderManager.start({
		    duration: 60000,
		    // 录音的时长，单位 ms，最大值 600000（10 分钟）
		    sampleRate: 44100,
		    // 采样率
		    numberOfChannels: 1,
		    // 录音通道数
		    encodeBitRate: 192000,
		    // 编码码率
		    format: 'aac' // 音频格式，选择此格式创建的音频消息，可以在即时通信 IM 全平台（Android、iOS、微信小程序和Web）互通
		  
		  });
		  // return new Promise((r,n)=>{
			 //  this.recorderManager.onStop((res)=>{
				// r(res)  
			 //  })
		  // })
	  	  // uni.showToast({
	  	  //   title:'1',
	  	  //   icon: 'none'
	  	  // });


	  },
	  
	  setsendRights(data){
		  return new Promise((r,n)=>{
		  sendRights(data).then(res=>{
		  	
			
			r(res)
			})
				// console.log('赠送权益',res)
			})
	  },
	  
    switchAudio() {
		// #ifdef MP-WEIXIN
		this.setData({
		  isAudio: !this.isAudio,
		  text: '按住说话'
		});
		// #endif
		// #ifdef APP-PLUS
		this.isAudio=!this.isAudio
		this.text='按住说话'
		// #endif
    },

    handleLongPress(e) {
		this.fs()
		console.log(e)

	  console.log(e.touches[0],'e.touches[0]')
	  // #ifdef MP-WEIXIN
	  this.setData({
	    startPoint: e.touches[0],
	    title: '正在录音',
	    // isRecording : true,
	    // canSend: true,
	    notShow: true,
	    isShow: false,
	    isRecording: true,
	    popupToggle: true,
	    recordTime: 0
	  });
	  // #endif
      // #ifdef APP-PLUS
      this.startPoint= e.touches[0]
      this.title= '正在录音'
      // isRecording : true,
      // canSend: true,
      this.notShow= true
      this.isShow= false
      this.isRecording= true
      this.popupToggle= true
      this.recordTime= 0
      // #endif
      this.recordTimer = setInterval(() => {
        this.recordTime++;
      }, 1000)
	  
    },

    // 录音时的手势上划移动距离对应文案变化
    handleTouchMove(e) {
      if (this.isRecording) {
        if (this.startPoint.clientY - e.touches[e.touches.length - 1].clientY > 100) {
          
		  // #ifdef MP-WEIXIN
		  this.setData({
		    text: '抬起停止',
		    title: '松开手指，取消发送',
		    canSend: false
		  });
		  // #endif
		  // #ifdef APP-PLUS
		  this.text= '抬起停止'
		  this.title= '松开手指，取消发送'
		  this.canSend= false
		  // #endif
        } else if (this.startPoint.clientY - e.touches[e.touches.length - 1].clientY > 20) {
          // this.setData({
          //   text: '抬起停止',
          //   title: '上划可取消',
          //   canSend: true
          // });
		  // #ifdef MP-WEIXIN
		  this.setData({
		    text: '抬起停止',
		    title: '上划可取消',
		    canSend: true
		  });
		  // #endif
		  // #ifdef APP-PLUS
		  this.text= '抬起停止'
		  this.title= '上划可取消'
		  this.canSend= true
		  // #endif
		  
        } else {
			console.log(this.recordTime)
          // this.setData({
          //   text: '抬起停止',
          //   title: '正在录音',
          //   canSend: true
          // });
		  // #ifdef MP-WEIXIN
		  this.setData({
		    text: '抬起停止',
		    title: '正在录音',
		    canSend: true
		  });
		  // #endif
		  // #ifdef APP-PLUS
		  this.text= '抬起停止'
		  this.title= '正在录音'
		  this.canSend= true
		  // #endif
		  
		  
		  
        }
      }
    },

    // 手指离开页面滑动
    handleTouchEnd() {
      this.setData({
        isRecording: false,
        popupToggle: false
      });
      uni.hideLoading();
      uni.getRecorderManager().stop();
	  console.log(this.recordTimer)
	  uni.getRecorderManager().onStop(res => {
	  	uni.showToast({
	  	  title:'2',
	  	  icon: 'none'
	  	}); 
	  // return false
	    clearInterval(this.recordTimer);
	    // 兼容 uniapp 打包app，duration 和 fileSize 需要用户自己补充
	    // 文件大小 ＝ (音频码率) x 时间长度(单位:秒) / 8
	    console.log(res,'resres')
	    uni.showToast({
	      title:res.tempFilePath,
	      icon: 'none'
	    });
	    
	    
	    let msg = {
	      duration: res.duration? res.duration : this.recordTime * 1000,
	      tempFilePath: res.tempFilePath,
	      fileSize: res.fileSize ? res.fileSize : (48 * this.recordTime) / 8 * 1024
	    }
	    
	    // return false
	    uni.hideLoading();
	    // 兼容 uniapp 语音消息没有duration
	    // if (this.canSend) {
	      if (msg.duration < 1000) {
	        uni.showToast({
	          title: '录音时间太短',
	          icon: 'none'
	        });
	      } else {
	  		uni.showToast({
	  		  title: '发送语音',
	  		  icon: 'none'
	  		});
	        // res.tempFilePath 存储录音文件的临时路径
	        const message = uni.$TUIKit.createAudioMessage({
	          to: this.getToAccount(),
	          conversationType: this.conversation.type,
	          payload: {
	            file: msg
	          }
	        });
	        this.$sendTIMMessage(message);
	      }
	    // }
	  // #ifdef MP-WEIXIN
	  this.setData({
	    startPoint: 0,
	    popupToggle: false,
	    isRecording: false,
	    canSend: true,
	    title: ' ',
	    text: '按住说话'
	  });
	  // #endif
	  // #ifdef APP-PLUS
	  this.startPoint= 0
	  this.popupToggle=false
	  this.isRecording=false
	  this.canSend= true
	  this.title= ' '
	  this.text= '按住说话'
	  // #endif  
	  });
	  
    },
    handleEmoji() {
      let targetFlag = 'emoji';

      if (this.displayFlag === 'emoji') {
        targetFlag = '';
      }

      this.setData({
        displayFlag: targetFlag
      });
    },

    handleExtensions() {
      let targetFlag = 'extension';

      if (this.displayFlag === 'extension') {
        targetFlag = '';
      }

      this.setData({
        displayFlag: targetFlag
      });
    },

    error(e) {
      console.log(e.detail);
    },

    handleSendPicture() {
      this.sendImageMessage('camera');
    },

    handleSendImage() {
      this.sendImageMessage('album');
    },

    sendImageMessage(type) {
      uni.chooseImage({
        sourceType: [type],
        count: 1,
        success: res => {
          if (res) {
            const message = uni.$TUIKit.createImageMessage({
              to: this.getToAccount(),
              conversationType: this.conversation.type,
              payload: {
                file: res
              },
              onProgress: percent => {
                message.percent = percent;
              }
            });
            this.$sendTIMMessage(message);
          }
        }
      });
    },

    handleShootVideo() {
      this.sendVideoMessage('camera');
    },

    handleSendVideo() {
      this.sendVideoMessage('album');
    },
	// 发送地理位置
	handleSendMap(){
		// uni.navigateTo({
		// 	url:'/pages/TUI-Chat/map/map'
		// })
		// uni.getLocation({
		//     type: 'gcj02',
		//     success:(res)=> {
		// 		console.log(res)
		//         console.log('当前位置的经度：' + res.longitude);
		//         console.log('当前位置的纬度：' + res.latitude);
		// 		return false
		// 		uni.navigateTo({
		// 			url:'/pages/TUI-Chat/map?longitude='+res.longitude+'&latitude='+res.latitude
		// 		})
		//     }
		// })
		
		this.getMapLocation();
	},
	sendMapMessage(location){
		
		const message = uni.$TUIKit.createLocationMessage({
		  to: this.getToAccount(),
		  conversationType: this.conversation.type,
		  payload: {
			title:location.name,
		    description:location.address,
		    longitude:location.longitude,
		    latitude:location.latitude,
		  },
		  onProgress: percent => {
		    message.percent = percent;
		  }
		});
		// console.log('地理信息',message)
		this.$sendTIMMessage(message);
	},
	handleSendnews(){
		// this.sendNewsMessage()
		this.setData({
		  displaynews: true
		})
	},
	// sendNewsMessage(){
	// 	console.log(this.getToAccount(),'this.conversation.type')
	// 	const message = uni.$TUIKit.createLocationMessage({
	// 	  to: this.getToAccount(),
	// 	  conversationType: this.conversation.type,
	// 	  payload: {
	// 		title:'this.conversation.title',
	// 	    img:'http://tansuo.wsframe.com/uploads/bj.jpg',
	// 	    id:'1',
	// 	    // latitude:location.latitude,
	// 	  },
	// 	  onProgress: percent => {
	// 	    message.percent = percent;
	// 	  }
	// 	});
	// 	// console.log('地理信息',message)
	// 	this.$sendTIMMessage(message);
	// },
	
	
	getMapLocation(){
		uni.chooseLocation({
				success:(res)=> {
					console.log('地理位置',res);
					
					this.sendMapMessage(res)
				},
				fail:(err)=>{
					console.log(err)
					// 如果用uni.chooseLocation没有获取到地理位置，则需要获取当前的授权信息，判断是否有地理授权信息
					uni.getSetting({
						success: (res) => {
							console.log(res);
							var status = res.authSetting;
							if(!status['scope.userLocation']){
							// 如果授权信息中没有地理位置的授权，则需要弹窗提示用户需要授权地理信息
								uni.showModal({
									title:"是否授权当前位置",
									content:"需要获取您的地理位置，请确认授权，否则地图功能将无法使用",
									success:(tip)=>{
										if(tip.confirm){
										// 如果用户同意授权地理信息，则打开授权设置页面，判断用户的操作
											uni.openSetting({
												success:(data)=>{
												// 如果用户授权了地理信息在，则提示授权成功
													if(data.authSetting['scope.userLocation']===true){
														uni.showToast({
															title:"授权成功",
															icon:"success",
															duration:1000
														})
														// 授权成功后，然后再次chooseLocation获取信息
														uni.chooseLocation({
															success: (res) => {
																// console.log("详细地址",res);
																this.sendMapMessage(res)
															}
														})
													}else{
														uni.showToast({
															title:"授权失败",
															icon:"none",
															duration:1000
														})
													}
												}
											})
										}
									}
								})
							}
						},
						fail: (res) => {
							uni.showToast({
								title:"调用授权窗口失败",
								icon:"none",
								duration:1000
							})
						}
					})
				}
			});
	},
    sendVideoMessage(type) {
      uni.chooseVideo({
        sourceType: [type],
        // 来源相册或者拍摄
        maxDuration: 60,
        // 设置最长时间60s
        camera: 'back',
        // 后置摄像头
        success: res => {
          if (res) {
            const message = uni.$TUIKit.createVideoMessage({
              to: this.getToAccount(),
              conversationType: this.conversation.type,
              payload: {
                file: res
              },
              onProgress: percent => {
                message.percent = percent;
              }
            });
            this.$sendTIMMessage(message);
          }
        }
      });
    },

    handleCommonFunctions(e) {
      switch (e.target.dataset.function.key) {
        case '0':
          this.setData({
            displayCommonWords: true
          });
          break;

        case '1':
          this.setData({
            displayOrderList: true
          });
          break;

        case '2':
          this.setData({
            displayServiceEvaluation: true
          });
          break;

        default:
          break;
      }
    },

    handleSendOrder() {
      this.setData({
        displayOrderList: true
      });
    },

    appendMessage(e) {
      this.setData({
        inputText: this.inputText + e.detail.message,
        sendMessageBtn: true
      });
    },

    getToAccount() {
      if (!this.conversation || !this.conversation.conversationID) {
        return '';
      }

      switch (this.conversation.type) {
        case 'C2C':
          return this.conversation.conversationID.replace('C2C', '');

        case 'GROUP':
          return this.conversation.conversationID.replace('GROUP', '');

        default:
          return this.conversation.conversationID;
      }
    },

    handleCalling(e) {
      // todo 目前支持单聊
      if (this.conversation.type === 'GROUP') {
        uni.showToast({
          title: '群聊暂不支持',
          icon: 'none'
        });
        return;
      }

      const type = e.currentTarget.dataset.value;
      const {
        userID
      } = this.conversation.userProfile;
      this.$emit('handleCall', {
        detail: {
          type,
          userID
        }
      });
      this.setData({
        displayFlag: ''
      });
    },

    sendTextMessage(msg, flag) {
		console.log(msg, flag)
		console.log(this.getToAccount(),'this.getToAccount()this.getToAccount()')
		// return false
      const to = this.getToAccount();
      const text = flag ? msg : this.inputText;
      const message = uni.$TUIKit.createTextMessage({
        to,
        conversationType: this.conversation.type,
        payload: {
          text
        }
      });
      this.setData({
        inputText: '',
        sendMessageBtn: false
      });
      this.$sendTIMMessage(message);
    },

    onInputValueChange(event) {
      if (event.detail.value) {
        this.setData({
          sendMessageBtn: true
        });
      } else {
        this.setData({
          sendMessageBtn: false
        });
      }
    },

    $handleSendTextMessage(event) {
      this.sendTextMessage(event.detail.message, true);
      this.setData({
        displayCommonWords: false
      });
    },

    $handleSendCustomMessage(e) {
		console.log( JSON.parse(e.detail.payload.extension).userID )
		// return false
		this.setsendRights({uid:JSON.parse(e.detail.payload.extension).userID}).then((res)=>{
			console.log(res) 
			if(res.data.code==1){
				const message = uni.$TUIKit.createCustomMessage({
				  to: this.getToAccount(),
				  conversationType: this.conversation.type,
				  payload: e.detail.payload
				});
				this.$sendTIMMessage(message);
				this.setData({
				  displayOrderList: false
				});
			}
			// if(){
				
			// }
		})
		// return false	
		// console.log(e,'$handleSendCustomMessage',this.conversation)
		
		// return false
      
    },
	$handleSendnews(e){
		console.log(e.detail.payload,'e.detail.payload')
		const message = uni.$TUIKit.createCustomMessage({
		  to: this.getToAccount(),
		  conversationType: this.conversation.type,
		  payload: e.detail.payload
		});
		this.$sendTIMMessage(message);
		this.setData({
		  displaynews: false
		});
	},
	
    $handleCloseCards(e) {
		// console.log('关闭card',e.detail.key)
      switch (e.detail.key) {
        case '0':
          this.setData({
            displayCommonWords: false
          });
          break;

        case '1':
          this.setData({
            displayOrderList: false
          });
          break;

        case '2':
          this.setData({
            displayServiceEvaluation: false
          });
          break;
		case '3':
		  this.setData({
		    displayPresent: false
		  });
		  break;
		case '4':
		    this.setData({
		      displaynews: false
		    });
		    break;
        default:
          break;
      }
    },

    $sendTIMMessage(message) {
      this.$emit('sendMessage', {
        detail: {
          message
        }
      });
      uni.$TUIKit.sendMessage(message)
      this.setData({
        displayFlag: ''
      });
    },

    handleClose() {
      this.setData({
        displayFlag: ''
      });
    },
	// 发送礼物
    handlePresent() {
      this.setData({
        displayPresent: true
      })
    },
	
	handleServiceEvaluation() {
	  this.setData({
	    displayServiceEvaluation: true
	  });
	},
    // inputBindFocus() {
    //   console.log("占位：函数 inputBindFocus 未声明");
    // },

    // inputBindBlur() {
    //   console.log("占位：函数 inputBindBlur 未声明");
    // }

  }
};
</script>
<style>
@import "./index.css";
</style>
